package com.ly.mpayment.persist.service.bill;

import com.ly.mpayment.persist.entity.BillOrder;
import com.ly.mpayment.persist.hibernate.Page;
import com.ly.mpayment.persist.service.AbstractService;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Map;

@Service
public class BillOrderServiceImpl extends AbstractService<BillOrder, Serializable> implements BillOrderService {

    @Override
    public boolean saveBill(BillOrder order) {
        this.saveOrUpdate(order);
        return true;
    }


    @Override
    public Page<BillOrder> findPageBillOrder(Map<String, Object> parameters, int start, int pageSize) {
        String sql = "select b from BillOrder b where 1 = 1 #[ and  b.type = :type ]#  #[ and  b.shopId = :useruuid ]# #[ and  b.createTime >= :starttime ]# " +
                " #[ and  b.createTime <= :endtime ]#  #[ and  b.fileType = :fileType ]#  order by b.createTime desc " ;
        return this.findPageByNamed(sql , parameters, start, pageSize);
    }


    @Override
    public void updateBill(BillOrder orderBill) {
        this.updateEntity(orderBill);
    }
}
